﻿#if UNITY_EDITOR
using System.Text;
/// <summary>
/// XLSX扩展
/// </summary>
public static class ESF_XlsxExtend
{
    /// <summary>
    /// xlsx表索引字母
    /// </summary>
    static readonly char[] mXlsxColumnOrdinalLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();

    /// <summary>
    /// XLSX列索引转换为字母索引
    /// </summary>
    /// <param name="_columnOrdinal">列索引</param>
    /// <returns>字母索引</returns>
    public static string XlsxColumnOrdinalToLetter(this int _columnOrdinal)
    {        
        StringBuilder sb = new StringBuilder();
        while (_columnOrdinal / mXlsxColumnOrdinalLetters.Length != 0)
        {
            sb.Append(mXlsxColumnOrdinalLetters[_columnOrdinal / mXlsxColumnOrdinalLetters.Length]);
            _columnOrdinal = _columnOrdinal % mXlsxColumnOrdinalLetters.Length;
        }
        _columnOrdinal = _columnOrdinal % mXlsxColumnOrdinalLetters.Length;
        sb.Append(mXlsxColumnOrdinalLetters[_columnOrdinal]);
        return sb.ToString();
    }
}
#endif
